CC   := gcc
CFLAG:= -m64 -ggdb3 -Wall -Werror 

INCS := -I./src
LIBS := -lpthread -lm 

vpath %.h ./src
vpath %.c ./src

OBJS:= ae.o updDispatch.o ralist.o 

TARGET:= updDispatch libupdDispatchApi.so libupdDispatchApi.a

all:${TARGET}
	@echo
	@echo
	@echo '*******************************************************'
	@echo 'make'
	@echo ' ${TARGET}'
	@echo 'successfully.'
	@-rm *.o
	@-[ ! -d api ] && mkdir api;echo "mkdir api"
	@-[ ! -d bin ] && mkdir bin;echo "mkdir bin"
	@-mv libupdDispatchApi.so libupdDispatchApi.a api
	@-cp ./src/updDispatchApi.h api
	@-mv updDispatch bin
	@echo '*******************************************************'
	@echo
	@echo

%.o:%.c
	${CC}  -c $< -o $@ ${CFLAG} ${INCS}

updDispatch:${OBJS}
	${CC}  $^  -o $@  ${LIBS} ${CFLAG}

libupdDispatchApi.so:updDispatchApi.c endianness.c
	${CC} -fPIC -shared $^ -o $@

libupdDispatchApi.a:updDispatchApi.o endianness.o
	ar -crs $@ $^
	ranlib $@

clean:
	@-rm -rf ${OBJS} 
	@-rm -rf ${TARGET} api bin
